﻿namespace RulesEngine
{
    public class AndRule<TCandidate> : CompositeRule<TCandidate>
    {
        public IRule<TCandidate> One;
        public IRule<TCandidate> Other;

        public AndRule(IRule<TCandidate> x, IRule<TCandidate> y)
        {
            One = x;
            Other = y;
        }

        public override bool Execute(TCandidate candidate)
        {
            return One.Execute(candidate) && Other.Execute(candidate);
        }
    }
}